//////读
var xlsx = require('node-xlsx').default;
var fs = require('fs');
const path = require('path');

const outputDataArr = [];
const firstFile = xlsx.parse(path.resolve('1.xlsx'));
const secondFile = xlsx.parse(path.resolve('2.xlsx'));
const thirdFile = xlsx.parse(path.resolve('3.xlsx'));
const workSheetsFromFiles = [firstFile, secondFile, thirdFile];

workSheetsFromFiles.forEach((excelObj, key) => {
  let excelSheet = excelObj[0].data; //表1 数据 array
  let arr = [];
  excelSheet.forEach(item => {
    let name = item[0];
    let nameObj = {
      name: name,
    };
    arr.push(nameObj);
  });
  outputDataArr.push(arr);
});

// 写
var str = JSON.stringify(outputDataArr);
fs.writeFile('./mock/person.json', str, function(err) {
  if (err) {
    console.error(err);
  }
  console.log('----------新增成功-------------');
});
